package com.loong.java.json.regex;

import scala.Tuple4;

import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
 * Created by 梁浩峰 on 2016/9/14 17:04.
 */
public class JavaRegexUtil {
    public static Tuple4<String, String, String, String> jsonRegx(String json) {
        String pattern = ".+send_time\\S:\\S(\\S+\\s\\S+\\s\\S+\\s\\S+\\s\\S+\\s\\S+)\",\"send_log_info\":\\S+\\s:\\s(.+})\",\"log_level\":\"(\\S+)\",\"send_log_address\":\"(\\S+)\"}.*";


        // 创建 Pattern 对象
        Pattern r = Pattern.compile(pattern);

        // 现在创建 matcher 对象
        Matcher m = r.matcher(json);
        if (m.find()) {
            return new Tuple4<String, String, String, String>(m.group(1), m.group(2), m.group(3), m.group(4));
        } else {
            return null;
        }
    }
}
